home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1999 July / Macworld (1999-07).dmg / Shareware World / Info / For Developers / Mops 3.4.sea / Mops source / Toolbox classes / Menu < prev    next >
Text File  |  1998-01-11  |  2KB  |  97 lines

  1. \ Menu class.
  2. \ Sept 90  mrh  item# anomalies fixed
  3. \ Sept 97  mrh    updated for PowerMops
  4.  
  5.  
  6. syscall NewMenu
  7. syscall GetMenu
  8. syscall MenuSelect
  9. syscall DrawMenuBar
  10. syscall ClearMenuBar
  11. syscall MenuKey
  12. syscall EnableItem
  13. syscall DisableItem
  14. syscall HiliteMenu
  15. syscall GetMenuItemText
  16. syscall SetMenuItemText
  17. syscall InsertMenuItem
  18. syscall DeleteMenuItem
  19. syscall InsertMenu
  20. syscall InsertResMenu
  21. syscall AppendMenu
  22. syscall AppendResMenu
  23. syscall CheckItem
  24. syscall OpenDeskAcc
  25. syscall SystemEdit
  26. syscall ReleaseResource
  27.  
  28.  
  29. from  MENUMOD  import{  MENU  APPLEMENU  EDITMENU  }
  30.  
  31. compile: menuMod
  32. lock: menuMod
  33. true setInstall: MenuMod
  34.  
  35.  
  36. : DODSK        \ ( item# -- )  Executes the desk accessory for an item.
  37.             \  Note we can send a late-bound msg to self even though we're
  38.             \  not lexically in a class, since this word will only be called
  39.             \  from a method.
  40.  
  41.     openDesk: [self]  ;
  42.  
  43.  
  44. : MSELECT    \ ( point -- item# menuID )   Calls menu manager to track a menu selection
  45.     MenuSelect  unpack swap 1- swap  ;
  46.  
  47.  
  48. :class    MBAR        super{ object }
  49.  
  50.    24    ordered-col    IDs
  51.    24    array        MENUS        \ array of menu objects
  52.  
  53. :m DRAW:    DrawMenuBar  ;m
  54.  
  55. :m CLEAR:    ClearMenuBar   clear: IDs  ;m
  56.  
  57. :m ADD:        \ ( men1 ... menN N -- )  Adds menu objects to the MenuBar object.
  58.  
  59.     0 DO  i to: menus  i at: menus  id: []  add: ids  LOOP  ;m
  60.  
  61. :m NEW:        \ Inserts menus in Toolbox MenuBar list.
  62.     size: IDs  0
  63.     DO   size: IDs  1- i -  at: menus  insert: []   LOOP
  64.     draw: self  ;m
  65.  
  66. :m INIT:        \ ( men1 ... menN N -- )
  67.     clear: self  add: self  new: self  ;m
  68.  
  69. :m EXEC:    \ ( item# MenuID -- )
  70.     dup 0>
  71.     IF        indexOf: IDs  IF  at: menus  exec: []  THEN
  72.     ELSE    2drop
  73.     THEN  ;m
  74.  
  75. :m CLICK:    where: fevent  mSelect  exec: self  ;m
  76.  
  77. :m KEY:        \ ( c -- )  Handles a possible menu key selection
  78.     MenuKey  unpack  swap 1- swap
  79.     exec: self  ;m
  80.     
  81. :m ENABLE:    \ Enables all menus in the Menu Bar
  82.     size: IDs  0
  83.     DO  i  at: menus  handle: []  0  EnableItem  LOOP
  84.     draw: self  ;m
  85.  
  86. :m DISABLE:
  87.     size: IDs  0
  88.     DO  i  at: menus  handle: []  0  DisableItem  LOOP
  89.     draw: self  ;m
  90.  
  91. ;class
  92.  
  93.  
  94. mBar    MENUBAR                \ Our default menu bar
  95.  
  96. menubar  put: MBaddr        \ Set as current menu bar
  97.